<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="btn">跳转</button>
    <script>
        // console.log(location);
        var btn = document.querySelector(".btn");
        btn.addEventListener('click', handleCallClick, false);
        var i = 0;
        function handleCallClick() {
            // location.href =  "https:www.baidu.com";
            // location.assign("https:www.baidu.com");
            // location.replace("https:www.baidu.com")
            console.log(location.toString());
            history.pushState(null, null, "/book" + ++i);
        }
        //练习：提取地址的查询参数
        //期望结果
        // {
        //   ie: 'utf-8',
        //   ...
        // }
        var requestUrl = 'https://www.baidu.com/s?ie=utf-8&f=3&rsv_bp=1&rsv_idx=1&tn=02003390_25_hao_pg&wd=%E7%8E%89%E7%B1%B3&fenlei=256&oq=%25E7%258E%2589%25E7%25B1%25B3&rsv_pq=c152a2960005400e&rsv_t=6762qqyrDQZnfiIZLxBwmV2UZZXkJpZvqzqbaMOP30OCKnvPtf07DjrYCqb3kQc6PZWGsmnQQODX&rqlang=en&rsv_enter=0&rsv_dl=ts_0&rsv_btype=t&prefixsug=%25E7%258E%2589%25E7%25B1%25B3&rsp=0';
        console.log(decodeURI(requestUrl));
        console.log(decodeURI(decodeURI(requestUrl)));
        function callDecode(data){
            if(/\%[a-zA-Z][0-9]/.test(data)===false) return data;
            return callDecode(decodeURI(data));
        }
        console.log(callDecode(requestUrl));
        var arr = decodeURI(decodeURI(requestUrl)).split("?")[1].split("&");
        console.log(arr);
        var cat = {};
        [].forEach.call(arr, function(item){
            cat[item.split("=")[0]] = item.split("=")[1];
        });
        console.log(cat);
    </script>
</body>

</html>